package Practice;

import java.util.Scanner;

public class SelectNumber {
    static int count = 0;
    static int k,n;
    static int[] x;

    public static boolean isPrime(int x){
        if (x < 2) return false;
        if (x == 2) return true;
        int x1 = (int) Math.sqrt(x);
        for (int i = 2; i <= x1; i++) {
            if (x%i==0)
                return false;
        }
        return true;
    }

    public static void dfs(int start,int deep,int sum){
        if (deep == k){
            if (isPrime(sum)){
                count++;
            }
            return;
        }
        for (int i = start; i < n; i++) {
            dfs(i+1,deep+1,sum+x[i]);
        }
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        k = sc.nextInt();
        x = new int[n];
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
        }
        dfs(0,0,0);
        System.out.println(count);
    }
}
